package com.java.websocket.bean;

import com.alibaba.fastjson.JSONObject;
import java.io.Serializable;

/**
 * 封装返回结果公共类
 *
 * @param
 * @author kevin_Xu
 * @date 2018/6/11 10:15
 * @return
 */
public class CommonResult <T> implements Serializable {

    //返回转态
    private boolean status = true;
    //提示信息
    private String msg;
    //返回结果
    private T result;
    //错误码
    private String code = "0";

    public CommonResult() {
        new CommonResult(true, "成功", null, "0");
    }

    public CommonResult(boolean status, String msg, T result, String code) {
        this.status = status;
        this.msg = msg;
        this.result = result;
        this.code = code;
    }

    public CommonResult(boolean status, String msg, String code) {
        this.status = status;
        this.msg = msg;
        this.code = code;
    }

    public CommonResult(T result) {
        this.msg = "成功";
        this.result = result;
    }

    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String toString() {
        return JSONObject.toJSONString(this);
    }
}
